package lab4;

import lab2.*;

import java.lang.reflect.InvocationTargetException;

public class EmployeeActionFD implements VisitorInterface {
    public void visit(Employee employee){
        try {
            VisitorInterface.class.getDeclaredMethod("visit",employee.getClass()).invoke(this,employee);
        } catch (IllegalAccessException e) {
            throw new RuntimeException(e);
        } catch (InvocationTargetException e) {
            throw new RuntimeException(e);
        } catch (NoSuchMethodException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public void visit(RegularStaff regularStaff) {
        System.out.println(regularStaff.getName()+"‘s salary is "+ SalaryReference.getSalary(regularStaff));
    }

    @Override
    public void visit(Intern intern) {
        System.out.println(intern.getName()+"‘s salary is "+SalaryReference.getSalary(intern));
    }

    public void visit(PartTimeJob partTimeJob){
        System.out.println(partTimeJob.getName()+"‘s salary is "+partTimeJob.getHours()*20.0);
    }
}
